package com.jzo2o.gateway.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一返回结果
 * @param <T>
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    public static final String REQUEST_OK = "OK"; // 请求成功
    private int code;
    private String msg;
    private T data;
    private String requestId; // 请求ID

    /**
     * 创建错误结果
     * @param code 状态码
     * @param msg 提示信息
     * @return 统一返回结果
     */
    public static Result<?> error(int code, String msg) {
        return new Result<>(code, msg, null, null);
    }
}
